package com.vmc;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.io.FileSystemUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.SystemUtils;

public class Test {
	public static String root = "D:/testarea";
	public static String NEW = "_NEW_";
	
	
	public void renameNewFiles(List<File> fileList) {
		if (fileList != null) {
			List<File> parentFileList = new ArrayList<File>();
			for (File file : fileList) {
				if (file.getAbsolutePath().equalsIgnoreCase(new File(root).getAbsolutePath()) || file.getName().contains(NEW)) {
					continue;
				}
				file.renameTo(new File(file.getParentFile().getAbsolutePath() + File.separator +  NEW + file.getName()));
				parentFileList.add(file.getParentFile());
			}
			if (parentFileList != null && parentFileList.size() > 0) {
				renameNewFiles(parentFileList);
			}
		}
	}

	public void renameNewFiles(File file) {
		try {
			if (file.getAbsolutePath().equalsIgnoreCase(new File(root).getAbsolutePath()) || file.getName().contains(NEW)) {
				return;
			}
			file.renameTo(new File(file.getParentFile().getAbsolutePath() + File.separator +  NEW + file.getName()));
			renameNewFiles(file.getParentFile());
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		//(new Test()).renameFile(new File("d:/testarea/_NEW_nf3/tst.mp4"));
		List<String> lstA = new ArrayList<String>();
		lstA.add("A");
		lstA.add("B");
		lstA.add("C");
		List<String> lstB = lstA;
		lstA = new ArrayList<String>();
		System.out.println(lstA.size());
		System.out.println(lstB.size());
	}
}
